
function conn(host, port) {
	this.websocket = new WebSocket('ws://' + host + ':' + port);
	console.log(this.websocket);
	this.websocket.onmessage = this.onRecv;

	this.websocket.onopen = function(msg) {
		alert("open");
	}
	
	this.send = function(data)
	{
		var _data = JSON.stringify(data);
		alert(_data);
		this.websocket.send(_data);
	}
	
	this.onRecv = function(msg)
	{
		try {
			alert("onmessage:" + msg.data);
			var parsed = JSON.parse(msg.data);
			alert(parsed);
		} catch (e) {
			console.warn(e);
			alert(e);
		}
	}

}
